
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The impact of divorce laws on the equilibrium in the marriage market.
% Ana Reynoso
% April 2024
%
% This file inputs coefficients and estandard errors from the event study
% and creates Figure 1.
%
% Data: PSID 1968-1992
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%------------------------ Replication Path -------------------------------%

clc
clear all

%--- Indicate location of Replication folder:
%replication_location = 'C:\update_with_your_path';

%------------------------ Preliminaries ----------------------------------%
input_dir = [replication_location,'\Evidence\Output'];

%--- Parameters for figures
x0=0;
y0=0;
width=1800;
height=1200;

%--- Load estimation results
data_imp = importdata([input_dir,'/Figure_1_Data.csv']);

%--- Organize data
Y = data_imp.data(1:13);
se = data_imp.data(14:end);
Y_l = Y - 1.96*se;
Y_u = Y + 1.96*se;
X=[-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 ];
periods = {'(>10)', '(10 to 9)', '(8 to 7)','(6 to 5)','(4 to 3)','(2 to 1)','Adoption','1 to 2','3 to 4','5 to 6','7 to 8','9 to 10','>10'};

%----------------------------- Figure 1 ----------------------------------%

plot(X,Y,'-o', 'MarkerFaceColor',[0.5,0.5,0.5],'Color', [0 0.3470 0.5410],'LineWidth',4)
hold on
plot(X,Y_l,'--',X,Y_u,'--','Color',[0.5,0.5,0.5],'LineWidth',2) 
hold on
yline(0,'LineWidth',2) 
hold on
yline(0.2682,'--') 
txt = 'Aggregate Effect = 0.2682';
text(-5.5,0.32,txt,'FontSize',20);
xticks(-6:6)
set(gca,'xticklabel',periods.','FontSize',24)
set(gcf,'position',[x0,y0,width,height])
xlabel('Years Since (Until) Adoption of Unilateral Divorce','FontSize',28,'FontWeight','bold') 
xline(0,'LineWidth',4,'Color','red') 
ylabel('Coefficient on Educ^h \times UD^{\{k\}} (\beta_2^k)','FontSize',28,'FontWeight','bold') 

%--- Save
cd ([replication_location,'\Evidence\Output']);
saveas(gcf, 'Figure_1.png')  

hold off
close